fix: suppress OkHttp default User-Agent header on outbound requests#30
fix: suppress OkHttp default User-Agent header on outbound requests#30chrismParticle wants to merge 1 commit into
Conversation
PR SummaryMedium Risk Overview Adds MockWebServer-based tests to verify no Reviewed by Cursor Bugbot for commit 29503b1. Bugbot is set up for automated code reviews on this repo. Configure here. |
e9b7eab to
0e389b2
Compare
Adds a UserAgentInterceptor (network interceptor) to ApiClient that removes the okhttp/<version> User-Agent header injected by OkHttp's BridgeInterceptor. This prevents mParticle from enriching device_info.http_header_user_agent with a meaningless SDK string. Caller-supplied User-Agent values are preserved. Wired in both createDefaultAdapter() and configureFromOkclient(). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
0e389b2 to
29503b1
Compare
Summary
UserAgentInterceptor(network interceptor) toApiClientthat strips OkHttp's defaultUser-Agentheader (okhttp/<version>) afterBridgeInterceptorinjects itcreateDefaultAdapter()andconfigureFromOkclient()so all construction paths are coveredUser-Agentvalues (set via a custom OkHttp interceptor) are detected and passed through unchangeddevice_info.http_header_user_agentwith a meaningless library-identifier stringVersion
Changelog entry added for
2.8.0.Test plan
ApiClientUserAgentTestcovers three cases usingMockWebServer: default path (no UA), caller override preserved, andconfigureFromOkclientpath./gradlew test— 9 tests, all passingdevice_info.http_header_user_agent; batch withUser-Agent: my_appshowsmy_appcorrectlyNotes
addNetworkInterceptor(notaddInterceptor) — required because OkHttp'sBridgeInterceptorruns between application and network interceptors and re-injects the default UA if the header is absent at the application layerRateLimitInterceptoris unchanged🤖 Generated with Claude Code